
<template>
  <div class="list">
    <!-- <Button type="primary" @click="$router.go(-1)">返回</Button> -->
    <!-- 将内容拆分出来三个组件 -->
    <!-- 1. 简单信息填写 -->
    <!-- 2. 商品属性填写 -->
    <!-- 3. 商品富文本 -->

    <!-- 727132985@qq.com -->
    <Button type="primary" @click="$router.go(-1)">返回</Button>
    <Tabs value="name1" style="border: solid 20px rgb(245, 247, 249)">
      <TabPane label="商品信息" name="info"
        ><Base @value="getAddListValue"></Base
      ></TabPane>
      <TabPane label="商品属性" name="attr">标签二的内容</TabPane>
      <TabPane label="商品详情" name="rich">
        <Rich @value="getRichValue"
      /></TabPane>
    </Tabs>
    <Button type="primary" @click="isOk">添加</Button>
  </div>
</template>
<script>
import Rich from "../../components/rich.vue";
import Base from "../../components/base.vue";
import { add } from "@/Api/base.js";
export default {
  name: "GoodsAdd",
  components: {
    Rich,
    Base,
  },
  data() {
    return {
      formData: null,
    };
  },
  methods: {
    getRichValue(e) {
      // console.log(e);
      this.formData.datail = e;
    },
    getAddListValue(e) {
      this.formData = e;
      console.log(this.formData);
    },
    isOk() {
      add(this.formData).then((res) => {
        // console.log(res);
        if (res.data.errCode == 0) {
          this.$Notice.success({
            title: "添加成功",
            onClose:() => {
              this.$router.push("/system/goodsList")
            },
          })
        }
        else{
          this.$Notice.error({
            title:"添加失败"
          })
        }
      });
    },
  },
};
</script>
<style scoped>
.list {
  width: 100%;
  margin: 0 0px;
  padding: 0px;
  margin-top: 50px;
}
</style>